<?php session_start(); ?>
<?php
 if(!$_SESSION['uname']){
  echo "你没有权限访问此页面!";
  return false;
}
?>
<?php include("../inc/db_config.inc"); ?>
<?php
if(isset($_REQUEST['title'])&&$_REQUEST['title']!=""){
    $notice_title=$_REQUEST['title'];
}else{
    echo "公告名称不能为空<a href='javascript:history.back()'>返回</a>";
    return false;
}
if(isset($_REQUEST['content'])&&$_REQUEST['content']!=""){
    if (get_magic_quotes_gpc()) {
			//$notice_cont = addslashes($_REQUEST['content']);
			$notice_cont =  stripslashes(trim($_REQUEST['content']));
		} else {
			$notice_cont = trim($_REQUEST['content']);
		}
		$notice_cont = str_replace('\'', "''", $notice_cont);
}else{
    echo "公告内容不能为空<a href='javascript:history.back()'>返回</a>";
    return false;
}

date_default_timezone_set("Asia/Shanghai"); //北京时间
$notice_created=date("Y-m-d H:i:s");
$notice_puber=1;
//echo "insert into type (name,cataDesc,created,status) values('$cata_title','$cata_desc','$cata_created','$cata_status')";
$result_post=mysql_query("insert into notice (title,cont,puber,created) values('".$notice_title."','".$notice_cont."','".$notice_puber."','".$notice_created."')");
if(mysql_affected_rows()>0){
    $ref=$_SERVER['HTTP_REFERER'];
    echo "添加成功!页面会在1秒钟后自动返回.<script type='text/javascript'>setTimeout(function(){window.location.href='$ref'},1000)</script>";
}else{
    echo "添加失败!<a href='javascript:history.back()'>返回</a>";
}
 ?>